Get a date, day, month or year

Get a date, day, month or year

There are functions which you can use in your rules to get particular dates, days, months or years.

What do you want to do?

Get today's date

Get the day component of an input date

Get the month component of an input date

Get the year component of an input date

Get the date from a date and time

Get a date formed from a specified year, month and day

Get today's date

To insert the system date into a rule, you use the Current Date function. To do this you insert the words "the current date" in the rule. NOTE: These words operate as a function and should therefore not be added as a variable attribute.

For example, the following comparison:

the date of assessment = the current date

will infer the date of assessment to be 12/12/2008 if the rule is run on 12/12/2008.

The current date can also be used as an input date in a calculation. For example:

the date 2 weeks from today = the date 2 weeks after the current date

will infer the date 2 weeks from today to be 26/12/2008 if the rule is run on 12/12/2008. Here the current date is the input date in an Add Weeks function.

NOTE: The Current Date function returns the system date at the start of the session.

Get the day component of an input date

To extract the day component of an input date (or date time), you use the Extract Day function. For example:

the day of expiry = ExtractDay(2009-01-08)

will infer the day of expiry to be 08. Note that the input date can be a constant as in this example, or a variable, as in the example below:

the day of expiry = ExtractDay(the use-by date on the packet)

Get the month component of an input date

To extract the month component of an input date (or date time), you use the Extract Month function. For example:

the birth month = ExtractMonth(2004-11-21)

will infer the birth month to be 11. Note that the input date can be a constant as in this example, or a variable, as in the example below:

the birth month = ExtractMonth(the date of birth)

Get the year component of an input date

To extract the year component of an input date (or date time), you use the Extract Year function. For example:

the year the warranty expires = ExtractYear(2013-11-21)

will infer the year the warranty expires to be 2013. Note that the input date can be a constant as in this example, or a variable, as in the example below:

the year the warranty expires = ExtractYear(the date 5 years after the purchase date)

Get the date from a date and time

To extract the date from a date and time attribute, you use the ExtractDate function. For example:

the date of manufacture = ExtractDate(the datetime of manufacture)

will infer the date of manufacture to be 2011-12-05 when the datetime of manufacture is 2011-12-05 11:31:45.

Get a date formed from a specified year, month and day

To form a date from a specified year, month and day, you use the Make date function. For example:

the calculation date = MakeDate(2007, 10, 17)

would make the calculation date 17-10-2007.

 

See also: